<template>
  <div class="view-container">

    <table-search-view ref="orderView" :search-items="searchItems" :table-items="tableItems" :search-function="search" >
      <template slot="action" slot-scope="scope">
        <action-confirm-receipt :scope="scope" @confirm-success="confirmSuccess"></action-confirm-receipt>
        <action-logistics :scope="scope" type="merchant"></action-logistics>
        <action-info :scope="scope"></action-info>
      </template>
    </table-search-view>

  </div>
</template>

<script>
  import TableSearchView from '@/components/TableSearchView';

  import actionOrderInfo from './components/actionOrderInfo.vue';
  import actionConfirmReceipt from './components/actionConfirmReceipt.vue';
  import actionLogistics from './components/actionLogistics.vue';

  import {getOrderReturningList} from '@/api/order';

  export default {
    name: 'orderReturning', /*退还中*/
    components: {
      'table-search-view':TableSearchView,
      'action-info':actionOrderInfo,
      'action-confirm-receipt':actionConfirmReceipt,
      'action-logistics':actionLogistics,
    },
    data ()
    {
      return {
        searchItems: [
          {
            label: '商品名称',
            type: 'autocomplete',
            placeholder:'请输入商品名称',
            model:'goodName',
          },
          {
            label: '到期时间',
            type: 'datetimerange',
            placeholder:'请选择到期时间',
            model:'timeRange',
          },
          {
            label: '订单编号',
            type: 'input',
            placeholder:'请输入订单编号',
            model:'orderId',
          },
          {
            label: '下单用户',
            type: 'input',
            placeholder:'请输入下单用户',
            model:'userName',
          }
        ],
        tableItems:[
          {
            label:'订单编号',
            prop:'orderNumber',
            width:'180px;',
          },
          {
            label:'商品名称',
            prop:'goodsName',
            width:'180px;',
            sortable:true,
          },
          {
            label:'下单用户',
            prop:'userName',
            width:'180px;',
            sortable:true,
          },
          {
            label:'退还方式',
            prop:'mode',
            width:'120px;',
            sortable:true,
          },
          {
            label:'寄出时间',
            prop:'returnTime',
            width:'160px;',
            formatter:'parseTime',
          },
          {
            label:'订单状态',
            prop:'stateStr',
            width:'100px;',
            sortable:true,
          },
          {
            label:'最新物流',
            prop:'newestExpress',
            width:'200px;',
          },
          {
            type:'scope',
            label:'操作',
            slot:'action',
            width:'220px;',
          },
          {

          }
        ],
      }
    },
    methods: {
      search(data)
      {
        return getOrderReturningList(data);
        /*return new Promise(resolve => {
          let resp = {data:{total:10, list:[
            {
              "id": 91484,
              "goodsName": "V5DXbZfkMV",
              "userName": "iaod1lHt1T",
              "mode": "快递",
              "returnTime": 1505974045102,
              "state": "XmMP6DHVJa",
              "stateStr": "退还中",
              "newestExpress": "已签收，签收人是 前台"
            },
            {
              "id": 91761,
              "goodsName": "RR06XXFs8n",
              "userName": "j01r4jHG3u",
              "mode": "快递",
              "returnTime": 1505972355881,
              "state": "zl0LMN4WR4",
              "stateStr": "退还中",
              "newestExpress": "已签收，签收人是 前台"
            },
          ]}};
          resolve(resp);
        });*/
      },
      confirmSuccess()
      {
        this.$refs['orderView'].search();
      }
    }
  }
</script>
